package com.zzyl.nursing.controller;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.dto.CheckInApplyDto;
import com.zzyl.nursing.vo.CheckInDetailVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.CheckIn;
import com.zzyl.nursing.service.ICheckInService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * checkInController
 * 
 * @author ruoyi
 * @date 2025-07-25
 */
@Tag(name = "checkIn")
@RestController
@RequestMapping("/nursing/checkIn")
public class CheckInController extends BaseController
{
    @Autowired
    private ICheckInService checkInService;

    @GetMapping("/detail/{id}")
    public R<CheckInDetailVo> detail(@PathVariable("id") Long id){

        CheckInDetailVo vo=checkInService.detail(id);

        return R.ok(vo);
    }





    @PostMapping("/apply")
    public AjaxResult apply(@RequestBody CheckInApplyDto dto){
        checkInService.apply(dto);
        return AjaxResult.success();
    }


    /**
     * 查询checkIn列表
     */
    @Operation(summary = "查询checkIn列表")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckIn checkIn)
    {
        startPage();
        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
        return getDataTable(list);
    }

    /**
     * 导出checkIn列表
     */
    @Operation(summary = "导出checkIn列表")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:export')")
    @Log(title = "checkIn", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckIn checkIn)
    {
        List<CheckIn> list = checkInService.selectCheckInList(checkIn);
        ExcelUtil<CheckIn> util = new ExcelUtil<CheckIn>(CheckIn.class);
        util.exportExcel(response, list, "checkIn数据");
    }

    /**
     * 获取checkIn详细信息
     */
    @Operation(summary = "获取checkIn详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@Parameter(description ="checkInID") @PathVariable("id") Integer id)
    {
        return success(checkInService.selectCheckInById(id));
    }

    /**
     * 新增checkIn
     */
    @Operation(summary = "新增checkIn")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:add')")
    @Log(title = "checkIn", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckIn checkIn)
    {
        return toAjax(checkInService.insertCheckIn(checkIn));
    }

    /**
     * 修改checkIn
     */
    @Operation(summary = "修改checkIn")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:edit')")
    @Log(title = "checkIn", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckIn checkIn)
    {
        return toAjax(checkInService.updateCheckIn(checkIn));
    }

    /**
     * 删除checkIn
     */
    @Operation(summary = "删除checkIn")
    @PreAuthorize("@ss.hasPermi('nursing:checkIn:remove')")
    @Log(title = "checkIn", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@Parameter(description = "checkInID集合") @PathVariable Integer[] ids)
    {
        return toAjax(checkInService.deleteCheckInByIds(ids));
    }
}
